#ifndef __BSP_CAN_MOTOR_SIMULATOR_H
#define __BSP_CAN_MOTOR_SIMULATOR_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "can.h"
#include <stdint.h>

/* Exported constants --------------------------------------------------------*/
#define MOTOR_ID               0x201
#define MOTOR_MAX_ANGLE        8192
#define MOTOR_CONTROL_ID_MIN   0x200
#define MOTOR_CONTROL_ID_MAX   0x2FF

/* Exported types ------------------------------------------------------------*/
#pragma pack(push, 1)
typedef struct {
    uint16_t angle;        // 编码器角度 0-8191
    int16_t  speed_rpm;    // 转速 RPM
    int16_t  current;      // 实际电流
    uint8_t  temperature;  // 温度
} Motor_Feedback_t;
#pragma pack(pop)

/* Exported functions prototypes ---------------------------------------------*/
void motor_simulator_init(void);
void send_motor_status(void);
void send_motor_status_manual(uint16_t angle, int16_t speed_rpm, int16_t current, uint8_t temperature);
void send_motor_status_auto_update(void);
void motor_simulator_test(void);

// Getter functions
uint16_t get_motor_angle(void);
int16_t get_motor_speed(void);
int16_t get_motor_current(void);
uint8_t get_motor_temperature(void);

// Setter functions  
void set_motor_angle(uint16_t angle);
void set_motor_speed(int16_t speed);
void set_motor_current(int16_t current);
void set_motor_temperature(uint8_t temp);

#ifdef __cplusplus
}
#endif

#endif /* __BSP_CAN_MOTOR_SIMULATOR_H */